package com.menhai.personmanagement.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.menhai.personmanagement.entity.MbHealthPlanAdvice;
import com.menhai.personmanagement.entity.MbHealthPlanModel;
import com.menhai.personmanagement.services.MbHealthPlanService;

import lombok.extern.slf4j.Slf4j;
/**
 * <p>
 * 健康计划 前端控制器
 * </p>
 *
 * @author shikun
 * @since 2021-11-25
 */

@Slf4j
@RestController
@RequestMapping("/healthPlan")
public class MbHealthPlanController {

     @Autowired
     private MbHealthPlanService mbHealthPlanService;
    
     
     /**
      * 健康计划显示患者
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/selectPatientList")
     public Object selectPatientList(HttpServletRequest request, HttpServletResponse response,MbHealthPlanAdvice mbHealthPlanAdvice){
    	String patientName = request.getParameter("patientName");
    	String newaddress = request.getParameter("newaddress");
    	String hosnum = request.getParameter("hosnum");
		return mbHealthPlanService.getListByCondition(patientName, newaddress,hosnum,mbHealthPlanAdvice);
     }
     
     
     /**
      * 新建健康建议模板
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/addMbHealthAdviceModel")
     public Object addMbHealthAdviceModel(MbHealthPlanModel mbHealthPlanModel){
    	//新建时间
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		mbHealthPlanModel.setCreateTime(sdf.format(new Date()));
		return mbHealthPlanService.addMbHealthAdviceModel(mbHealthPlanModel);
     }
     
     
     /**
      * 健康计划显示患者
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/getAdviceModelListByCondition")
     public Object getAdviceModelListByCondition(HttpServletRequest request, HttpServletResponse response){
    	String hosnum = request.getParameter("hosnum");
    	String adviceKind = request.getParameter("adviceKind");
		return mbHealthPlanService.getAdviceModelListByCondition(hosnum,adviceKind);
     }
     
     /**
      * 删除建议模板
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/deleteAdviceModel")
     public Object deleteAdviceModel(HttpServletRequest request, HttpServletResponse response){
    	String modelId = request.getParameter("modelId");   	 
		return mbHealthPlanService.deleteAdviceModel(modelId);
     }
     
     
     /**
      * 新建健康建议
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/addMbHealthAdvice")
     public Object addMbHealthAdvice(MbHealthPlanAdvice mbHealthPlanAdvice){
    	//新建时间
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		mbHealthPlanAdvice.setAddTime(sdf.format(new Date()));
		return mbHealthPlanService.addMbHealthAdvice(mbHealthPlanAdvice);
     }
     
     /**
      * 查看健康建议
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/getAdviceListByCondition")
     public Object getAdviceListByCondition(HttpServletRequest request, HttpServletResponse response){
    	String hosnum = request.getParameter("hosnum");
    	String bkbh = request.getParameter("bkbh");
    	String headerTitle = request.getParameter("headerTitle");
		return mbHealthPlanService.getAdviceListByCondition(hosnum,bkbh,headerTitle);
     }
     
     /**
      * 修改健康模板
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/updateMbHealthAdviceModel")
     public Object updateMbHealthAdviceModel(MbHealthPlanModel mbHealthPlanModel){
    	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    	mbHealthPlanModel.setCreateTime(sdf.format(new Date()));
		return mbHealthPlanService.updateMbHealthAdviceModel(mbHealthPlanModel);
     }
 	
}
